﻿using System;
using MenesDroid;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace XNA_Game_Engine.Canvas
{
    class Frame : Canvas
    {
        protected int X, Y;
        protected int FrameWidth, FrameHeight;
        protected bool _enabled, closable;

        public Frame(Game game, int x, int y, int frameWidth, int frameHeight, bool closable )
        {
            this.X = x;
            this.Y = y;
            Width = game.Window.ClientBounds.Width;
            Height = game.Window.ClientBounds.Height;

            this.FrameWidth = frameWidth;
            this.FrameHeight = frameHeight;

            this.closable = closable;

            Buttons = new Botoes();
            Rand = new Random();
            _enabled = false;
        }


        public override void LoadContent(ContentManager Content)
        {
            Background = Content.Load<Texture2D>(@"Game_Backgrounds\frame_back");

            if (closable)
            {
                /*Buttons.Add(new clsButton(Content.Load<Texture2D>(@"Buttons\close_button"),
                                       Content.Load<Texture2D>(@"Buttons\close_button"),
                                       new Vector2(X + FrameWidth - 30, Y + 10), new Vector2(20, 20),
                                       CloseButtonEvent));*/
            }
        }


        public override void Update(GameTime gameTime)
        {
            if( _enabled )
                Buttons.Update();
        }


        public override void Render(SpriteBatch renderTarget)
        {
            if (!_enabled) 
                return;

            renderTarget.Draw(Background, new Rectangle(X, Y, FrameWidth, FrameHeight), new Color(255, 255, 255, 150));
            Buttons.Draw(renderTarget);
        }
		
		
		public bool Enabled{
			get { return _enabled; }
			set { _enabled = value; }
		}
		

        #region Close
        public void CloseButtonEvent(object sender, EventArgs e)
        {
            this._enabled = false;
        }
        #endregion
        
    } //class
}//namespace
